import {
  setStore,
  getStore
}
from './mUtils'

/*
 * 申请状态
 */
const getIssueStatus = function(value) {
  var str = "";
  switch(value - 0) {
    case 0:
      str = "授信失败";
      break;
    case 1:
      str = "授信成功";
      break;
  }
  return str;
}

const getReoaymentStatus = function(value) {
  var str = "";
  switch(value - 0) {
    case 1:
      str = "代扣失败";
      break;
    case 2:
      str = "代扣成功";
      break;
    case 3:
      str = "代扣中";
      break;
  }
  return str;
}
const getChannelBackStatus = function(value) {
  var str = "";
  switch(value - 0) {
    case 1:
      str = "是";
      break;
    case 2:
      str = "否";
      break;
  }
  return str;
}
const getUserBlackSource = function(value) {
  return {
    "risk": "盒子风控",
    "unionpay": "中国银联",
    "other": "其它"
  }[value];
}

const getOverdue = function(value) {
  var str = "";
  switch(value - 0) {
    case 1:
      str = "一级";
      break;
    case 2:
      str = "二级";
      break;
    case 3:
      str = "三级";
      break;
    case 4:
      str = "四级";
      break;
  }
  return str;
}

/*
 * 催收方式
 */
const getCollectionType = function(value) {
  var str = "";
  switch(value - 0) {
    case 1:
      str = "短信催收";
      break;
    case 2:
      str = "电话催收";
      break;
    case 3:
      str = "法律催收";
      break;
  }
  return str;
}

const getAuditAprStatus = function(v) {
  return {
    "0": "审核通过",
    "1": "未激活",
    "2": "已激活",
    "3": "提交待审核",
    "4": "拒绝待修改",
    "5": "审核不通过",
    "6": "初审通过"
  }[v];
}

/*
 * 只有是和否还有未知这三种装态，统一用这个方法
 */
const yesOrno = function(v) {
  return {
    "0": "是",
    "1": "否",
    "2": "未知"
  }[v];
}

const getOprSource = function(v) {
  return {
    "0": "批量导入",
    "1": "人工修改"
  }[v];
}
const getUcZmxyScoreResponseDto = function(v) {
  return {
    "true": "认证成功",
    "false": "认证失败"
  }[v];
}

/*
 * 还款方式
 */
const getChargeType = function(v) {
  const list = {
    "1": "系统代扣",
    "2": "手工代扣",
    "3": "主动还款",
    "4": "线下转账"
  }
  return v == undefined ? list : list[v];
}

const getAuditauditStatus = function(v) {
  return {
    "0": "未审核",
    "1": "审核通过",
    "2": "审核不通过"
  }[v];
}

const getApplyLogStatus = function(v) {
  return {
    "1": "借款成功",
    "2": "借款中",
    "3": "借款失败"
  }[v];
}

const getHuankuangFangShi = function(v) {
  const list = {
    "0": "一次性还款",
    "1": "分期还款"
  }
  return v == undefined ? list : list[v]
}

const getCustomerStatus = function(v) {
  return {
    "2": "启用",
    "3": "停用"
  }[v];
}
const getStatus = function(v) {
  return {
    "0": "启用",
    "1": "停用"
  }[v];
}
const getCreditInventmentStatus = function(v) {
  return {
    "1": "已启用",
    "2": "停用"
  }[v];
}
const getContarceTemplateStatus = function(v) {
  return {
    "0": "正常",
    "1": "关闭"
  }[v];
}
const getContarceTemplateContractType = function(v) {
  return {
    "1": "合同类",
    "2": "协议类"
  }[v];
}

const getSupportTypeStatus = function(v) {
  return {
    "1": "借款",
    "2": "还款"
  }[v];
}

const getUserStatus = function(v) {
  return {
    "0": "正常",
    "1": "停用"
  }[v];
}
const getBankType = function(v) {
  return {
    "1": "贷记卡",
    "2": "借记卡"
  }[v];
}

const getRiskAprResult = function(v) {
  return {
    "0": "通过",
    "1": "拒绝",
    "2": "人工审核"
  }[v];
}
const getRiskConverings = function(value) {
  var str = "";
  switch(value - 0) {
    case 1:
      str = "逾期一级";
      break;
    case 2:
      str = "逾期二级";
      break;
    case 3:
      str = "逾期三级";
      break;
    case 4:
      str = "逾期四级";
      break;
  }
  return str;
}
const getUnit = function(value) {
  var str = "";
  switch(value - 0) {
    case 0:
      str = "日";
      break;
    case 1:
      str = "月";
      break;
    case 2:
      str = "年";
      break;
  }
  return str;
}

/*
 * 合同状态
 */
const getLoanContractStatus = function(v) {
  const list = {
    "1": "未还款",
    "2": "未还清",
    "3": "已逾期",
    "4": "按时还款",
    "5": "提前还款",
    "6": "逾期已还款",
    "7": "借款中",
    "8": "借款失败",
    "9": "分期还款中"
  }
  return v == undefined ? list : list[v]
}

/*
 * 还款结果
 */
const getRepayResultStatus = function(v) {
  return {
    "0": "还款失败",
    "1": "还款成功",
    "2": "还款中"
  }[v];
}

const getFormatterCode = function(v) {
  return {
    "0": "失败",
    "1": "成功",
    "2": "未知"
  }[v];
}

const getPlatformRecordType = function(v) {
  return {
    "1": "借款",
    "2": "还款"
  }[v];
}
const getPlatformRecordTypeRecoResult = function(v) {
  return {
    "1": "代付",
    "2": "代扣"
  }[v];
}

const getContractTemplateSubType = function(v) {
  if(1 == v) {
    //001-借款合同 002-产品服务协议 003-担保合同 004-债权转让合同 005-第三方转让合同 006-代扣服务协议 007-个人授信协议 008-借款合同(分期)
    return new Array(
      new Array("001", "借款合同"),
      new Array("003", "担保合同"),
      new Array("004", "债权转让合同"),
      new Array("005", "第三方转让合同"),
      new Array("008", "借款合同（分期）")
    );
  } else {
    return new Array(
      new Array("002", "产品服务协议"),
      new Array("006", "代扣服务协议"),
      new Array("007", "个人授信协议")
    );
  }
}

/*
 * 筛选结果
 */
const getFilterStatusStr = function(name) {
  return {
    "0": "通过",
    "1": "拒绝"
  }[name];
}

/*
 * 联系人类型
 */
const getlinkType = function(type) {
  return {
    "1": "亲属",
    "2": "高频联系人",
    "3": "随机联系人"
  }[type];
}

/*
 * 充值状态
 */
const getRechargeStatus = function(v) {
  return {
    "0": "待审核",
    "1": "审核通过",
    "2": "审核未通过",
    "3": "充值成功",
    "4": "充值失败",
    "5": "已撤销"
  }[v];
}

/*
 * 通道类型     20180131yuxinyan新增
 */
const getChanelType = function(v) {
  var list = {
    0: "代付",
    1: "代收"
  }
  return v == undefined ? list : list[v];
}

/*
 * 通道状态     20180131yuxinyan新增
 */
const getChanelStatus = function(v) {
  var list = {
    "0": "待启用",
    "1": "启用",
    "2": "停用"
  }
  return v == undefined ? list : list[v];
}

/*
 * 鉴权类型     20180131yuxinyan新增
 */
const getAuthenticationType = function(v) {
  var list = {
    1: "银行三要素",
    2: "银行四要素"
  }
  return v == undefined ? list : list[v];
}

/*
 * 规则类型     20180131yuxinyan新增
 */
const getRuleType = function(v) {
  var list = {
    0: "指定规则",
    1: "普通规则"
  }
  return v == undefined ? list : list[v];
}

// 对象深拷贝
const ObjectCopy = function(source) {
  let result = {};
  for(let key in source) {
    result[key] = typeof source[key] === 'object' ? ObjectCopy(source[key]) : source[key];
  }
  return result;
}

export default { 
  getIssueStatus,
  getReoaymentStatus,
  getChannelBackStatus,
  getUserBlackSource,
  getOverdue,
  getCollectionType,
  getAuditAprStatus,
  yesOrno,
  getOprSource,
  getUcZmxyScoreResponseDto,
  getChargeType,
  getAuditauditStatus,
  getApplyLogStatus,
  getHuankuangFangShi,
  getCustomerStatus,
  getStatus,
  getCreditInventmentStatus,
  getContarceTemplateStatus,
  getContarceTemplateContractType,
  getSupportTypeStatus,
  getUserStatus,
  getBankType,
  getRiskAprResult,
  getRiskConverings,
  getUnit,
  getLoanContractStatus,
  getRepayResultStatus,
  getFormatterCode,
  getPlatformRecordType,
  getFormatterCode,
  getPlatformRecordTypeRecoResult,
  getContractTemplateSubType,
  getFilterStatusStr,
  getlinkType,
  getRechargeStatus,
  getChanelType,
  getChanelStatus,
  getAuthenticationType,
  getRuleType,
  ObjectCopy
}